
import { ElMessage } from "element-plus"
import component from "element-plus/es/components/tree-select/src/tree-select-option.mjs"
import { createRouter, createWebHashHistory } from "vue-router"

let routes= [
    {
        path: '/',
        name: 'app',
        //使用import可以路由懒加载，如果不使用，太多组件一起加载会造成白屏
        component: () => import('@/App.vue'),
        children: [
            {
                path:   '/',
                name:   'Login',
                component: () => import('@/views/users/Login.vue'),
            },
            
        ]
    },
    {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/Home.vue'),
        meta:{
            title:'首页'
        },
        children: [
            {
                path:   '/myAccount',
                name:   'MyAccount',
                component: () => import('@/views/users/MyAccount.vue'),
                meta:{title: '账户'},
            },
            {
                path:   '/main',
                name:   'Main',
                component: () => import('@/views/mainViews/Main.vue'),
            },
            {
                path:   '/bookMain',
                name:   'BookMain',
                component: () => import('@/views/mainViews/books/BookMain.vue'),
                meta:{
                    title:'图书列表'
                },
                children:[
                    {
                        path:   '/bookInfo/?bookId',
                        name:   'BookInfo',
                        component:  ()=> import('@/views/mainViews/books/BookInfo.vue'),
                        meta:{
                            title:'图书详情'
                        },
                    },
                    {
                        path:   '/books',
                        name:   'Books',
                        component: () => import('@/views/mainViews/books/Books.vue'),
                        
                    },
                ]
            },
            
            {
                path:   '/shelve',
                name:   'Shelve',
                component: () => import('@/views/mainViews/shelve/Shelve.vue'),
                meta:{
                    title:'我的上架'
                },
                children:[
                    {
                        path:   '/goShelve',
                        name:   'GoShelve',
                        component:  ()=> import('@/views/mainViews/shelve/GoShelve.vue'),
                        meta:{
                            title:'上架'
                        },
                    },
                    {
                        path:   '/myShelve',
                        name:   'MyShelve',
                        component: () => import('@/views/mainViews/shelve/MyShelve.vue'),
                        
                    }
                ]
            },
            
            {
                path:   '/borrow',
                name:   'Borrow',
                component: () => import('@/views/mainViews/borrow/Borrow.vue'),
                meta:{
                    title:'我的借阅'
                },
                children:[
                    
                    {
                        path:   '/borrowInfo',
                        name:   'BorrowInfo',
                        component: () => import('@/views/mainViews/borrow/BorrowInfo.vue'),
                        meta:{
                            title:'借阅详情'
                        },  
                    },
                    {
                        path:   '/myBorrow',
                        name:   'MyBorrow',
                        component: () => import('@/views/mainViews/borrow/MyBorrow.vue'),
                        
                    }
                ]
            },
            
            {
                path:   '/about',
                name:   'About',
                component: () => import('@/views/mainViews/About.vue'),
                meta:{
                    title:'关于我们'
                },
            },
            {
                path:   '/message',
                name:   'Message',
                component:  ()=> import('@/views/mainViews/message/Message.vue'),
                meta:{
                    title:'消息'
                },
                
                children:[
                    {
                        path:   '/email/:letterId',
                        name:   'Email',
                        component:  () => import("@/views/mainViews/message/Email.vue"),
                        meta:{
                            title:'邮件'
                        },
                    },
                    {
                        path:   '/newEmail',
                        name:   'NewEmail',
                        component:  () => import("@/views/mainViews/message/NewEmail.vue"),
                        meta:{
                            title:'写邮件'
                        },
                    },
                    {
                        path:   '/replyEmail/:sender/:recipient',
                        name:   'ReplyEmail',
                        component:  () => import("@/views/mainViews/message/ReplyEmail.vue"),
                        meta:{
                            title:'回信'
                        },
                    },
                    {
                        path:   '/question/:questionId',
                        name:   'Question',
                        component:  () => import("@/views/mainViews/message/Question.vue"),
                        meta:{
                            title:'咨询'
                        },
                    },
                    {
                        path:   '/notice/:noticeId',
                        name:   'Notice',
                        component: () => import('@/views/mainViews/message/Notice.vue'),
                        meta:{
                            title:'公告'
                        },
                    },
                    {
                        path:   '/newNotice',
                        name:   'NewNotice',
                        component: () => import('@/views/mainViews/message/NewNotice.vue'),
                        meta:{
                            title:'新建公告'
                        },
                    },
        
                ]
            },
        ]
    },
    
    

]
// 路由
const router = createRouter({
    history: createWebHashHistory(),
    routes,
})



// 导出
export default router
